import Rect from './rect'

function canvas(id) {
  const el = document.getElementById(id)
  const ctx = el.getContext('2d')
  return { el, ctx }
}

function line(ctx, { moveX = 0, moveY = 0, lineX = 0, lineY = 0 }) {
  // 起始坐标
  ctx.moveTo(moveX, moveY)
  // x坐标，y坐标
  ctx.lineTo(lineX, lineY)
  ctx.stroke()
}

// function rect(ctx, { color = 'white', x = 0, y = 0, width = 0, height = 0 }) {
//   ctx.fillStyle = color
//   // 起始x、y坐标，长和宽
//   ctx.fillRect(x, y, width, height)
// }

export { canvas, line, Rect }
